package top.aicats.pattern.singleton.hungrySingleton;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class HungrySingletonTest {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Thread thread = new Thread(new Runnable() {
            public void run() {
                HungrySingleton instance = HungrySingleton.getInstance();
                System.out.println(instance);
            }
        });
        thread.start();

        Class<?> clazz = HungrySingleton.class;
        Constructor c=clazz.getDeclaredConstructor(null);

        c.setAccessible(true);
        HungrySingleton instance2 =(HungrySingleton) c.newInstance();
        System.out.println(instance2);

    }
}
